@tool
class_name ControllerCommand_ReleaseSkill
extends ControllerCommand

## 释放技能

#region 属性
@export var skill_id:String
## 当没有这个Skill时是否自动添加该技能
@export var is_auto_add_when_no_skill:bool = true
@export var release_args:Dictionary[String,Variant]
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
func activate(controller:ControllerComponent,command_dict_by_tag:Dictionary) -> bool:
	if not super(controller,command_dict_by_tag):
		return false
	var target = controller.entity as Entity
	var skill_component:SkillComponent = target.get_component(SkillComponent)
	if skill_component:
		if is_auto_add_when_no_skill:
			skill_component.get_skill_agent().add_skill(skill_id)
		skill_component.get_skill_agent().release_skill(skill_id,release_args)
	return true
func deactivate(controller:ControllerComponent,command_dict_by_tag:Dictionary):
	var target = controller.entity as Entity
	var skill_component:SkillComponent = target.get_component(SkillComponent)
	if skill_component:
		skill_component.get_skill_agent().cancel_skill(skill_id)
	super(controller,command_dict_by_tag)
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _init() -> void:
	if Engine.is_editor_hint():
		resource_local_to_scene = true
#endregion
